Skip to content

chore: add integration smoke test script + harden .gitignore#5

Merged
OussemaFr merged 2 commits into
mainfrom
chore/integration-smoke-test
Jun 22, 2026
Merged

chore: add integration smoke test script + harden .gitignore#5
OussemaFr merged 2 commits into
mainfrom
chore/integration-smoke-test

Conversation

@OussemaFr

Copy link
Copy Markdown
Member

What

Adds `scripts/integration_smoke.py` for local validation against the live socialapis.io REST API. One call per major endpoint category, reports per-method pass/fail, never prints the API token.

Also hardens `.gitignore` with defense-in-depth entries for env / token files (`.env`, `.env.`, `.token`, `.socialapis_token`) so an accidental commit can't land a secret in public history.

Why a script instead of CI tests

Mocked tests (current) Live smoke test (new)
Where CI on every PR Local, manual
Needs Nothing `SOCIALAPIS_TOKEN` env var
Catches Wire-level (URLs, headers, params, error mapping logic) Real-shape bugs (envelope drift, Pydantic field name mismatches, API contract drift)
Speed Fast (~1s) ~15s (real network)
When to run Always Before shipping a big change
Token leak risk None None (env-only, never printed)

Putting the smoke test in CI would mean either putting a token in GitHub Actions secrets (leak surface) or manual-trigger workflows (low ROI). Local-only is the right shape — re-run before any major SDK release.

Usage

```bash
export SOCIALAPIS_TOKEN=""
pip install -e .
python scripts/integration_smoke.py
```

The script:

  • Refuses to start if `SOCIALAPIS_TOKEN` isn't set
  • Never prints the token value
  • Catches and reports each test independently (one failure doesn't abort the run)
  • For typed-model methods, reports which Pydantic fields actually populated (so we spot schema mismatches)
  • Consumes ~13 credits per full run — stays well inside the 200/month free tier

What the first run found

Validation context only — the fix is a follow-up PR.

Good news: all 12 endpoint calls work at the wire level. Auth, routing, `**kwargs` forwarding, and `AuthenticationError` mapping all confirmed working.

Bad news: the three typed-model methods (`get_page_info`, `get_profile_details`, `get_group_details`) all return Pydantic models with no populated fields, because:

  1. Envelope shape is inconsistent across endpoints:

    • FB `/facebook/pages/details` wraps the payload under key `"0"` (a string)
    • IG `/instagram/profile/details` wraps under `"data"` + has a `"success"` sibling
    • FB `/facebook/groups/details` has NO wrapper — payload is spread alongside the envelope keys
  2. Field names don't match my models:

    • `PageInfo` declares `likes`; API returns `likes_count`
    • `PageInfo` declares `followers`; API returns `followers_count`
    • `ProfileInfo` declares `posts_count`; API returns `media_count`
    • etc.

Follow-up PR will fix the envelope extractor + correct field names, then bump to v0.1.1.

Test plan

After merging:

  • No secrets in the diff (`git log -p` shows only script + .gitignore)
  • `ruff check scripts/` passes
  • `python scripts/integration_smoke.py` runs cleanly with a valid token

Adds scripts/integration_smoke.py for local validation against the
live socialapis.io REST API. The script makes one call per major
endpoint category (Facebook pages/groups/search/ads/marketplace,
Instagram profile/posts/search/reels, Account usage, plus two
error-mapping checks) and reports per-method pass/fail.

Why a script instead of CI tests:
- Real API tests need a token, which means either a secret in CI
  (leak surface) or manual-trigger workflows (low ROI)
- The mocked tests already cover wire-level behavior in CI
- A local smoke test catches the bugs mocks can't: wrong endpoint
  paths, Pydantic field name mismatches, envelope shape drift
- One run is enough; this is a "before shipping a big change"
  ritual, not continuous

The script reads SOCIALAPIS_TOKEN from env, never prints the value,
never persists it. It's gitignored-by-association via the .gitignore
additions for .env/.token files.

Also hardens .gitignore with defense-in-depth entries for env files
and tokens (.env, .env.*, *.token, .socialapis_token) so an accidental
commit doesn't land a secret in public history.

What the first run found (validation context, fix in a follow-up PR):
- All 12 endpoint calls work at the wire level — auth, routing,
  forwarding kwargs all good
- AuthenticationError mapping works correctly (bad token → 401)
- But the typed-model methods (get_page_info, get_profile_details,
  get_group_details) all return Pydantic models with no populated
  fields, because the real API:
    a) Wraps responses in inconsistent envelopes (key "0" for FB
       pages, "data" for IG profiles, no wrapper at all for FB
       groups)
    b) Uses different field names than my models guessed
       (likes_count not likes, followers_count not followers,
       media_count not posts_count, etc.)

Follow-up PR will fix the envelope extractor + correct field names,
then bump to v0.1.1.
The smoke test reads `page.id` and probes `BadRequestError` with a
nonexistent slug. Both assumptions need adjusting after the typed-
model rewrite in #6:

- PageInfo now uses `ad_page_id` (and `user_id`) — the API doesn't
  return a bare `id` field for pages. Updated the assertion.
- The API returns 200 with an empty payload for nonexistent page
  slugs, not a 4xx. To still validate the SDK's error mapping
  works against a real 4xx, the test now sends a deliberately
  malformed request (no params) which the API rejects with 400.

Stays self-contained — no new dependencies, no changes outside
scripts/integration_smoke.py.
@OussemaFr OussemaFr merged commit 66c3b20 into main Jun 22, 2026
6 checks passed
@OussemaFr OussemaFr deleted the chore/integration-smoke-test branch June 22, 2026 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant